const Router = require("@koa/router");
const commentRouter = new Router({ prefix: "/comment" });

// 发表评论的中间件
const {
	create,
	reply,
	update,
	remove,
	list
} = require("../controller/comment.controller");

// 登录校验的中间件
const { verifyAuth, verifyPerm } = require("../middleware/auth.middleware");
const commentRequest = require("../request/comment.request");

// 评论
commentRouter.post("/", verifyAuth, commentRequest, create);
// 回复评论
commentRouter.post("/reply/:commentId", verifyAuth, commentRequest, reply);
// 修改评论
commentRouter.patch("/:commentId", verifyAuth, verifyPerm, update);
// 删除评论
commentRouter.delete("/:commentId", verifyAuth, verifyPerm, remove);
// 获取评论列表
commentRouter.get("/", list);

module.exports = commentRouter;
